USB UART 6 Click
USB UART 6 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.
Click Library
- Author : Stefan Filipovic
- Date : Jul 2025.
- Type : UART type
Software Support
Example Description
This example demonstrates the USB UART 6 Click board's ability to act as a USB-to-UART bridge. It enables bidirectional communication between a USB host and a UART device by forwarding received data between the USB and UART interfaces.
Example Libraries
- MikroSDK.Board
- MikroSDK.Log
- Click.USBUART6
Example Key Functions
- usbuart6_cfg_setup This function initializes Click configuration structure to initial values.
void usbuart6_cfg_setup(usbuart6_cfg_t *cfg)
USB UART 6 configuration object setup function.
USB UART 6 Click configuration object.
Definition usbuart6.h:130
- usbuart6_init This function initializes all necessary pins and peripherals used for this Click board.
err_t usbuart6_init(usbuart6_t *ctx, usbuart6_cfg_t *cfg)
USB UART 6 initialization function.
USB UART 6 Click context object.
Definition usbuart6.h:108
- usbuart6_generic_write This function writes a desired number of data bytes by using UART serial interface.
err_t usbuart6_generic_write(usbuart6_t *ctx, uint8_t *data_in, uint16_t len)
USB UART 6 data writing function.
- usbuart6_generic_read This function reads a desired number of data bytes by using UART serial interface.
err_t usbuart6_generic_read(usbuart6_t *ctx, uint8_t *data_out, uint16_t len)
USB UART 6 data reading function.
- usbuart6_enable_device This function enables the device by setting the EN pin to high logic state.
void usbuart6_enable_device(usbuart6_t *ctx)
USB UART 6 enable device function.
Application Init
Initializes the logger and the Click board and enables the device.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
Delay_ms ( 100 );
uart_read( &usbuart6.uart, app_buf, 1 );
uart_read( &logger.uart, app_buf, 1 );
}
#define USBUART6_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition usbuart6.h:93
void application_init(void)
Definition main.c:39
Application Task
Continuously reads the data from one UART interface and forwards it to the other, enabling seamless USB to UART data transfer and vice versa.
{
if ( uart_bytes_available ( &logger.uart ) )
{
if ( app_buf_len > 0 )
{
uart_write ( &usbuart6.uart, app_buf, app_buf_len );
memset( app_buf, 0, app_buf_len );
app_buf_len = 0;
}
}
if ( uart_bytes_available ( &usbuart6.uart ) )
{
if ( app_buf_len > 0 )
{
uart_write ( &logger.uart, app_buf, app_buf_len );
memset( app_buf, 0, app_buf_len );
app_buf_len = 0;
}
}
}
void application_task(void)
Definition main.c:76
#define PROCESS_BUFFER_SIZE
Definition main.c:31
Note
Make sure the USB UART 6 Click is properly connected to a USB host and the mikroBUS socket, and that both UART interfaces are configured for the same baud rate.
Application Output
This Click board can be interfaced and monitored in two ways:
- Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
- UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.
Additional Notes and Information
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.